package org.kwisatz.proxybot.filters;

import java.net.URLEncoder;

import javax.xml.xpath.XPathConstants;

import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
import org.w3c.dom.Document;
import org.w3c.dom.Node;

public class Aghate {
	public static void main(String[] args) {
		try
		{
			HttpClient httpClient = new HttpClient();
			String s=URLEncoder.encode("salut", "UTF-8");
			GetMethod get = new GetMethod("http://www.aghate.org/prog/tri.asp?Motuser="+s);
			System.out.println("http://www.aghate.org/prog/tri.asp?Motuser="+s);
			get.addRequestHeader(new Header("Host","www.aghate.org"));
			httpClient.executeMethod(get);			
			
			System.out.println(get.getStatusCode());
			while(get.getStatusCode()==302)
			{				
				get = new GetMethod(get.getResponseHeader("Location").getValue());
				System.out.println(get);
				httpClient.executeMethod(get);
			}
		}
		catch(Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
